Clover coverage report - Enterprise Web Services - 1.0
Coverage timestamp: Mon May 30 2005 17:10:32 CEST
file stats: LOC: 149   Methods: 6
NCLOC: 89   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
WebEndpointWrapperClassWriter.java 81.2% 93.8% 100% 91.4%
coverage coverage
 1   
 /*
 2   
  * Copyright 2001-2004 The Apache Software Foundation.
 3   
  * 
 4   
  * Licensed under the Apache License, Version 2.0 (the "License");
 5   
  * you may not use this file except in compliance with the License.
 6   
  * You may obtain a copy of the License at
 7   
  * 
 8   
  *      http://www.apache.org/licenses/LICENSE-2.0
 9   
  * 
 10   
  * Unless required by applicable law or agreed to in writing, software
 11   
  * distributed under the License is distributed on an "AS IS" BASIS,
 12   
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13   
  * See the License for the specific language governing permissions and
 14   
  * limitations under the License.
 15   
  */
 16   
 package org.apache.geronimo.ews.ws4j2ee.toWs.wrapperWs;
 17   
 
 18   
 import org.apache.commons.logging.Log;
 19   
 import org.apache.commons.logging.LogFactory;
 20   
 import org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext;
 21   
 import org.apache.geronimo.ews.ws4j2ee.context.SEIOperation;
 22   
 import org.apache.geronimo.ews.ws4j2ee.context.j2eeDD.WebContext;
 23   
 import org.apache.geronimo.ews.ws4j2ee.toWs.GenerationFault;
 24   
 import org.apache.geronimo.ews.ws4j2ee.toWs.JavaClassWriter;
 25   
 import org.apache.geronimo.ews.ws4j2ee.toWs.UnrecoverableGenerationFault;
 26   
 
 27   
 import java.util.ArrayList;
 28   
 import java.util.Iterator;
 29   
 
 30   
 /**
 31   
  * <h4>WebEndpoint Based Serivce Implementation Bean</h4>
 32   
  * <p>The Service Implementation Bean must follow the Service Developer requirements outlined in the JAX-RPC specification and are listed below except as noted.</p>
 33   
  * <ol>
 34   
  * <li>?The Service Implementation Bean must have a default public constructor.</li>
 35   
  * <li>?The Service Implementation Bean may implement the Service Endpoint
 36   
  * Interface as defined by the JAX-RPC Servlet model. The bean must implement
 37   
  * all the method signatures of the SEI. In addition, a Service Implementation
 38   
  * Bean may be implemented that does not implement the SEI. This additional
 39   
  * requirement provides the same SEI implementation flexibility as provided by
 40   
  * EJB service endpoints. The business methods of the bean must be public and
 41   
  * must not be static.</li>
 42   
  * <li>If the Service Implementation Bean does not implement the SEI, the
 43   
  * business methods must not be final. The Service Implementation Bean
 44   
  * may implement other methods in addition to those defined by the SEI,
 45   
  * but only the SEI methods are exposed to the client.  </li>
 46   
  * <li>?A Service Implementation must be a stateless object. A Service
 47   
  * Implementation Bean must not save client specific state across method
 48   
  * calls either within the bean instance���s data members or external to
 49   
  * the instance. A container may use any bean instance to service a request.</li>
 50   
  * <li>?The class must be public, must not be final and must not be abstract.</li>
 51   
  * <li>?The class must not define the finalize() method.</li>
 52   
  * </ol>
 53   
  *
 54   
  * @author Srinath Perera(hemapani@opensource.lk)
 55   
  */
 56   
 public class WebEndpointWrapperClassWriter extends JavaClassWriter {
 57   
     protected static Log log =
 58   
             LogFactory.getLog(WrapperWsGenerator.class.getName());
 59   
     protected String seiName = null;
 60   
     private String implBean = null;
 61   
 
 62   
     /**
 63   
      * @param j2eewscontext
 64   
      * @param qulifiedName
 65   
      * @throws GenerationFault
 66   
      */
 67  3
     public WebEndpointWrapperClassWriter(J2EEWebServiceContext j2eewscontext)
 68   
             throws GenerationFault {
 69  3
         super(j2eewscontext, getName(j2eewscontext) + "Impl");
 70  3
         seiName = j2eewscontext.getMiscInfo().getJaxrpcSEI();
 71  3
         WebContext webcontext = j2eewscontext.getWebDDContext();
 72  3
         if (webcontext == null) {
 73  0
             throw new UnrecoverableGenerationFault("for webbased Impl" +
 74   
                     " the WebDDContext must not be null");
 75   
         }
 76  3
         implBean = webcontext.getServletClass();
 77   
     }
 78   
 
 79  3
     private static String getName(J2EEWebServiceContext j2eewscontext) {
 80  3
         String name = j2eewscontext.getWSDLContext().gettargetBinding().getName();
 81  3
         if (name == null) {
 82  0
             name = j2eewscontext.getMiscInfo().getJaxrpcSEI();
 83   
         }
 84  3
         return name;
 85   
     }
 86   
 
 87  3
     protected String getimplementsPart() {
 88  3
         return " implements "
 89   
                 + j2eewscontext.getMiscInfo().getJaxrpcSEI() + ",org.apache.geronimo.ews.ws4j2ee.wsutils.ContextAccessible";
 90   
     }
 91   
 
 92  3
     protected void writeAttributes() throws GenerationFault {
 93  3
         out.write("private " + implBean + " bean = null;\n");
 94  3
         out.write("private org.apache.axis.MessageContext msgcontext;\n");
 95   
     }
 96   
 
 97  3
     protected void writeConstructors() throws GenerationFault {
 98  3
         out.write("\tpublic " + classname + "()throws org.apache.axis.AxisFault{\n");
 99  3
         out.write("\t\tbean = (" + implBean + ")org.apache.geronimo.ews.ws4j2ee.wsutils.ImplBeanPool.getImplBean(\""
 100   
                 + implBean + "\");\n");
 101  3
         out.write("\t}\n");
 102   
     }
 103   
 
 104   
     /* (non-Javadoc)
 105   
      * @see org.apache.geronimo.ews.ws4j2ee.toWs.JavaClassWriter#writeMethods()
 106   
      */
 107  3
     protected void writeMethods() throws GenerationFault {
 108  3
         out.write("\tpublic void setMessageContext(org.apache.axis.MessageContext msgcontext){;\n");
 109  3
         out.write("\t\tthis.msgcontext = msgcontext;\n");
 110  3
         out.write("\t}\n");
 111  3
         String parmlistStr = null;
 112  3
         ArrayList operations = j2eewscontext.getMiscInfo().getSEIOperations();
 113  3
         for (int i = 0; i < operations.size(); i++) {
 114  13
             parmlistStr = "";
 115  13
             SEIOperation op = (SEIOperation) operations.get(i);
 116  13
             String returnType = op.getReturnType();
 117  13
             if (returnType == null)
 118  2
                 returnType = "void";
 119  13
             out.write("\tpublic " + returnType + " " + op.getMethodName() + "(");
 120  13
             Iterator pas = op.getParameterNames().iterator();
 121  13
             boolean first = true;
 122  13
             while (pas.hasNext()) {
 123  12
                 String name = (String) pas.next();
 124  12
                 String type = op.getParameterType(name);
 125  12
                 if (first) {
 126  11
                     first = false;
 127  11
                     out.write(type + " " + name);
 128  11
                     parmlistStr = parmlistStr + name;
 129   
                 } else {
 130  1
                     out.write("," + type + " " + name);
 131  1
                     parmlistStr = parmlistStr + "," + name;
 132   
                 }
 133   
             }
 134  13
             out.write(") throws java.rmi.RemoteException");
 135  13
             ArrayList faults = op.getFaults();
 136  13
             for (int j = 0; j < faults.size(); j++) {
 137  0
                 out.write("," + (String) faults.get(j));
 138   
             }
 139  13
             out.write("{\n");
 140  13
             if (!"void".equals(returnType))
 141  11
                 out.write("\t\treturn bean." + op.getMethodName() + "(" + parmlistStr + ");\n");
 142   
             else
 143  2
                 out.write("\t\tbean." + op.getMethodName() + "(" + parmlistStr + ");\n");
 144  13
             out.write("\t}\n");
 145   
         }
 146   
     }
 147   
 
 148   
 }
 149